package com.LearnInWorld.video.mapper;

import com.LearnInWorld.video.pojo.Course;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface CourseMapper extends Mapper<Course> {

    @Select("SELECT a.id,a.sn,a.name,a.caption,a.video_id AS videoId, c.module_id AS moduleId, c.module_name AS moduleName, a.image,a.images,a.introduction,a.course_upTime AS courseUpTime,a.pay,a.price,a.comment_num AS commentNun,a.video_url AS videoUrl,b.id AS categoryId, b.name AS categoryName FROM tb_course a,tb_category b ,tb_module c WHERE a.category_id=b.id AND b.module_id=c.tb_id")
    List<Course> findAll();

    @Select("SELECT a.id,a.sn,a.name,a.caption,a.video_id AS videoId, c.module_id AS moduleId, c.module_name AS moduleName, a.image,a.images,a.introduction,a.course_upTime AS courseUpTime,a.pay,a.price,a.comment_num AS commentNun,a.video_url AS videoUrl,b.id AS categoryId, b.name AS categoryName FROM tb_course a,tb_category b ,tb_module c WHERE a.id=#{courseId} AND a.category_id=b.id AND b.module_id=c.tb_id")
    Course findCourseById(@Param("courseId") String courseId);
}
